// SwagDataGridAS.as
// ActionScript file for SwagDataGrid.mxml
// DWS: 6/26/06

import flash.net.Responder;

import mx.controls.Alert;
import mx.core.Application;

private var _ItemName:String;
private var _ItemCount:Number;
private var _ItemDescription:String;
private var _ItemID:Number;

[Bindable]
public var swagDataProvider:Array ;

private function initSwag():void  {
	trace("initSwag()");
	this.addEventListener("change", onDgChange,false,0,true);
	trace("initSwag exit");
}
private function readAllSwag():void {
	doReadUzerSwagBag(Application.application._Uzer_ID);	
	// doReadAllUzers();
}
public function doReadUzerSwagBag(uzer_id:int ):void {
	swagDataProvider = new Array( new Array("Noodle of Ecstasy",1));
//	Application.application._amfphpGateway.call( "gib.doReadUzerSwagBag", new Responder(respondReadUzerSwag, respondFault),uzer_id);
}
public function respondReadUzerSwag( result : Array ) : void {	
//	trace(result);
	swagDataProvider = result;
}	
public function respondFault( fault : String ) : void
{
	trace( "SwagDataGrid:onFault: "+fault );
}
//Called when datagrid is clicked.
private function onDgChange(evtObj:Object):void {

	var datagrid:Object = evtObj.target;
	var data:Object = datagrid.dataProvider.getItemAt(datagrid.selectedIndex);
	trace("onDgChange: "+data);
	if(data == null)
	{
//		newItem(null);
	}
	else
	{
		_ItemName =  data.Name; 
		_ItemCount = data.Count;
		_ItemDescription = data.Description;
		_ItemID = data.ItemID;
		trace("Item Name: "+_ItemName);
	}
}

public function get ItemName():String {
	return this._ItemName;
}
public function get SwagCount():Number {
	return this._ItemCount;
}
public function get ItemDescription():String {
	return this._ItemDescription;
}
public function get ItemID():Number {
	return this._ItemID;
}

